CREATE DATABASE BanVeXemPhim
GO
USE [BanVeXemPhim]
GO
/****** Object:  Table [dbo].[PhongChieu]    Script Date: 08/20/2013 12:51:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[PhongChieu](
	[MaPhongChieu] [int] NOT NULL,
	[Phong] [nchar](10) NOT NULL,
	[SoLuongChoNgoi] [int] NOT NULL,
 CONSTRAINT [PK_PhongChieu] PRIMARY KEY CLUSTERED 
(
	[MaPhongChieu] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Phim]    Script Date: 08/20/2013 12:51:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Phim](
	[MaPhim] [int] NOT NULL,
	[TenPhim] [nvarchar](50) NULL,
	[DaoDien] [nvarchar](50) NULL,
	[NamSanXuat] [datetime] NULL,
	[ThoiLuong] [nvarchar](50) NULL,
 CONSTRAINT [PK_Phimg] PRIMARY KEY CLUSTERED 
(
	[MaPhim] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Loai]    Script Date: 08/20/2013 12:51:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Loai](
	[MaLoai] [int] NOT NULL,
	[TenLoai] [nvarchar](50) NULL,
	[KhuyenMai] [nvarchar](50) NULL,
	[Gia] [int] NULL,
 CONSTRAINT [PK_LoaiVe] PRIMARY KEY CLUSTERED 
(
	[MaLoai] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[KhachHang]    Script Date: 08/20/2013 12:51:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[KhachHang](
	[MaKH] [int] NOT NULL,
	[TenKH] [nvarchar](50) NULL,
	[DiaChi] [nvarchar](50) NULL,
	[SDT] [nchar](11) NULL,
	[CMND] [nchar](10) NULL,
 CONSTRAINT [PK_KhachHang] PRIMARY KEY CLUSTERED 
(
	[MaKH] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[HoaDon]    Script Date: 08/20/2013 12:51:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[HoaDon](
	[MaHoaDon] [int] NOT NULL,
	[MaKH] [int] NULL,
	[NgayDatVe] [datetime] NULL,
	[NgayThanhToan] [datetime] NULL,
	[TinhTrang] [tinyint] NULL,
 CONSTRAINT [PK_HoaDon] PRIMARY KEY CLUSTERED 
(
	[MaHoaDon] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ChoNgoi]    Script Date: 08/20/2013 12:51:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ChoNgoi](
	[MaChoNgoi] [int] NOT NULL,
	[MaPhongChieu] [int] NOT NULL,
	[MaLoai] [int] NOT NULL,
	[Gia] [int] NULL,
 CONSTRAINT [PK_ChoNgoi] PRIMARY KEY CLUSTERED 
(
	[MaChoNgoi] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[XuatChieu]    Script Date: 08/20/2013 12:51:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[XuatChieu](
	[MaXuatChieu] [int] NOT NULL,
	[MaPhongChieu] [int] NOT NULL,
	[SoLuongVe] [int] NOT NULL,
	[ThoiGianChieu] [datetime] NOT NULL,
 CONSTRAINT [PK_XuatChieu] PRIMARY KEY CLUSTERED 
(
	[MaXuatChieu] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Ve]    Script Date: 08/20/2013 12:51:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Ve](
	[MaVe] [int] NOT NULL,
	[MaPhim] [int] NULL,
	[MaHoaDon] [int] NULL,
	[MaXuatChieu] [int] NULL,
	[ChoNgoi] [nchar](10) NULL,
	[TrangThai] [smallint] NULL,
 CONSTRAINT [PK_Ve] PRIMARY KEY CLUSTERED 
(
	[MaVe] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [FK_ChoNgoi_Loai]    Script Date: 08/20/2013 12:51:51 ******/
ALTER TABLE [dbo].[ChoNgoi]  WITH CHECK ADD  CONSTRAINT [FK_ChoNgoi_Loai] FOREIGN KEY([MaLoai])
REFERENCES [dbo].[Loai] ([MaLoai])
GO
ALTER TABLE [dbo].[ChoNgoi] CHECK CONSTRAINT [FK_ChoNgoi_Loai]
GO
/****** Object:  ForeignKey [FK_ChoNgoi_PhongChieu]    Script Date: 08/20/2013 12:51:51 ******/
ALTER TABLE [dbo].[ChoNgoi]  WITH CHECK ADD  CONSTRAINT [FK_ChoNgoi_PhongChieu] FOREIGN KEY([MaPhongChieu])
REFERENCES [dbo].[PhongChieu] ([MaPhongChieu])
GO
ALTER TABLE [dbo].[ChoNgoi] CHECK CONSTRAINT [FK_ChoNgoi_PhongChieu]
GO
/****** Object:  ForeignKey [FK_HoaDon_KhachHang]    Script Date: 08/20/2013 12:51:51 ******/
ALTER TABLE [dbo].[HoaDon]  WITH CHECK ADD  CONSTRAINT [FK_HoaDon_KhachHang] FOREIGN KEY([MaKH])
REFERENCES [dbo].[KhachHang] ([MaKH])
GO
ALTER TABLE [dbo].[HoaDon] CHECK CONSTRAINT [FK_HoaDon_KhachHang]
GO
/****** Object:  ForeignKey [FK_Ve_HoaDon]    Script Date: 08/20/2013 12:51:51 ******/
ALTER TABLE [dbo].[Ve]  WITH CHECK ADD  CONSTRAINT [FK_Ve_HoaDon] FOREIGN KEY([MaHoaDon])
REFERENCES [dbo].[HoaDon] ([MaHoaDon])
GO
ALTER TABLE [dbo].[Ve] CHECK CONSTRAINT [FK_Ve_HoaDon]
GO
/****** Object:  ForeignKey [FK_Ve_Phim]    Script Date: 08/20/2013 12:51:51 ******/
ALTER TABLE [dbo].[Ve]  WITH CHECK ADD  CONSTRAINT [FK_Ve_Phim] FOREIGN KEY([MaPhim])
REFERENCES [dbo].[Phim] ([MaPhim])
GO
ALTER TABLE [dbo].[Ve] CHECK CONSTRAINT [FK_Ve_Phim]
GO
/****** Object:  ForeignKey [FK_Ve_XuatChieu]    Script Date: 08/20/2013 12:51:51 ******/
ALTER TABLE [dbo].[Ve]  WITH CHECK ADD  CONSTRAINT [FK_Ve_XuatChieu] FOREIGN KEY([MaXuatChieu])
REFERENCES [dbo].[XuatChieu] ([MaXuatChieu])
GO
ALTER TABLE [dbo].[Ve] CHECK CONSTRAINT [FK_Ve_XuatChieu]
GO
/****** Object:  ForeignKey [FK_XuatChieu_PhongChieu]    Script Date: 08/20/2013 12:51:51 ******/
ALTER TABLE [dbo].[XuatChieu]  WITH CHECK ADD  CONSTRAINT [FK_XuatChieu_PhongChieu] FOREIGN KEY([MaPhongChieu])
REFERENCES [dbo].[PhongChieu] ([MaPhongChieu])
GO
ALTER TABLE [dbo].[XuatChieu] CHECK CONSTRAINT [FK_XuatChieu_PhongChieu]
GO
